﻿#ifndef CSensorSeriesTrandChar_H
#define CSensorSeriesTrandChar_H
/********************************************************************************
** @ Date:2025/01/09
** @ Author: HanJiaXin
** @ Description:声振温趋势图
** @ Version:1.0.0
** @ ClassName:CSensorSeriesTrandChart
** @ Fun:
********************************************************************************/
#include <QWidget>
#include <QMediaPlayer>
#include "ui_CSensorSeriesTrandChart.h"
#include "QCPToolTip.h"
#include "CDevSensorSeries.h"

struct SHistryData
{
	QString sTime;
	double dTemperatureData;
	double dAccelerationData;
	SHistryData()
	{
		sTime = "";
		dTemperatureData = 0;
		dAccelerationData = 0;
	}
};

class CSensorSeriesTrandChart : public QWidget
{
	Q_OBJECT

public:
	CSensorSeriesTrandChart(CDevSensorSeries* pDev,int nChannel, QWidget *parent = nullptr);
	CSensorSeriesTrandChart(CDevSensorSeries* pDev, QWidget *parent = nullptr);
	~CSensorSeriesTrandChart();

private:
	void initConnect();//初始化槽函数连接
	void setStyleSheetFile();//设置界面的样式表
	void initUi();//初始化界面

	void analyHistoryData(QString sResult);//解析历史数据
	void analyAcceleration(QString sFile);//解析加速度csv文件
	void analyAudio(QString sFile);//解析加速度csv文件

public slots:
	void slotQuery();//点击查询按钮槽函数
	void slotResult(int nRequestType, QString sResult);
	void slotTrandChartMouseMove(QMouseEvent *event);
	void slotAccelerationMouseMove(QMouseEvent *event);
	void slotPlottableClick(QCPAbstractPlottable *plottable, int dataIndex, QMouseEvent *event);
	void slotPlayAudio();//点击播放按钮
	void onComboBoxTextChanged(const QString &text);

private:
	Ui::CSensorSeriesTrandChartClass ui;
	CDevSensorSeries* m_pDev;
	CDevDataSensorSeries* m_pDevData;
	int m_nChannel;//通道号
	QCPToolTip  *m_pTrandTooltip;  // 显示趋势图坐标的文本项
	QCPToolTip  *m_pAccelerationTooltip;  // 显示加速度图坐标的文本项
	QMediaPlayer *m_pMediaPlayer;
	bool isPlaying;
	QByteArray m_audioData;//音频
	QDateTime m_ClickedTime;
};

#endif